%doctype{ :html => "true" }
  %head
    %meta{ :charset => "utf-8" }
    %title
      #{@report.report_name} Presentation
    %meta{ :name => "apple-mobile-web-app-capable", :content => "yes" }
    %meta{ :name => "apple-mobile-web-app-status-bar-style", :content => "black-translucent" }
    %meta{ :name => "viewport", :content => "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" }

    %link{ :rel => "stylesheet", :href => "/reveal.js/css/reveal.css" }
    %link{ :rel => "stylesheet", :href => "/reveal.js/css/print/paper.css" }
    %link#theme{ :rel => "stylesheet", :href => "/reveal.js/css/theme/beige.css" }
    %link{ :rel => "stylesheet", :href => "/reveal.js/lib/css/zenburn.css" }

    :javascript
      if(window.location.search.match(/print-pdf/gi)){
        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = '/reveal.js/css/print/pdf.css';
        document.getElementsByTagName('head')[0].appendChild(link);
      }
    %script{ :src => "/reveal.js/lib/js/html5shiv.js" }
  .reveal
    .slides
      %section
        %section
          %h1
            #{@report.report_name}
        %section
          %a{ :href => "/" }
            Return To Serpico
          :plain
            <br>
            Change Theme: <br>
            <!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. -->
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/black.css'); return false;">Black (default)</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/white.css'); return false;">White</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/league.css'); return false;">League</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/sky.css'); return false;">Sky</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/beige.css'); return false;">Beige</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/simple.css'); return false;">Simple</a> <br>
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/serif.css'); return false;">Serif</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/blood.css'); return false;">Blood</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/night.css'); return false;">Night</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/moon.css'); return false;">Moon</a> -
            <a href="#" onclick="document.getElementById('theme').setAttribute('href','/reveal.js/css/theme/solarized.css'); return false;">Solarized</a>

      %section{ :style => "vertical-align:top; text-align: left;" }
        %h2
          Findings Summary
        %table{ :style => "margin-left:10%" }
          - @findings.each do |finding|
            :ruby
              # set the color in here
              risk_types = ["Informational", "Low", "Moderate", "High", "Critical"]
                if @dread
                  risk_d = finding.dread_total/10
                  risk_d = 4 if finding.dread_total == 50
                  risk = risk_types[risk_d]
                else
                  risk = risk_types[finding.risk]
                end
                if risk == "Critical"
                color = "#FF4500"
              elsif risk == "High"
                color = "#FF8C00"
              elsif risk == "Moderate"
                color = "#0000FF"
              elsif risk == "Low"
                color = "#006400"
              else
                color = "#000000"
              end
            %tr
              %td
                #{finding.title}
              %td
                %span{ :style => "color:#{color};" }
                  #{risk.upcase}
      - @findings.each do |finding|
        %section
          %section{ :style => "vertical-align:top; text-align: left;" }
            %h2
              #{finding.title}
            %p{ :style => "margin-left:10%" }
              Risk
              :ruby
                # set the color in here
                risk_types = ["Informational", "Low", "Moderate", "High", "Critical"]
                  if @dread
                    risk_d = finding.dread_total/10
                    risk_d = 4 if finding.dread_total == 50
                    risk = risk_types[risk_d]
                  else
                    risk = risk_types[finding.risk]
                  end
                  if risk == "Critical"
                  color = "#FF4500"
                elsif risk == "High"
                  color = "#FF8C00"
                elsif risk == "Moderate"
                  color = "#0000FF"
                elsif risk == "Low"
                  color = "#006400"
                else
                  color = "#000000"
                end
              %span{ :style => "color:#{color}; font-size:120%" }
                #{risk.upcase}
            - if finding.presentation_points
              %ul{ :style => "margin-left:10%" }
                - finding.presentation_points.to_s.split("<paragraph>").each do |pp|
                  - next if pp =~ /\[\!\!/
                  - if pp.gsub('</paragraph>','').size > 0
                    %li
                      #{pp.gsub('</paragraph>','')}

          %section{ :style => "vertical-align:top; text-align: left;" }
            %h2
              #{finding.title}
            %h3
              Proof Of Concept
          - if finding.presentation_points
            - finding.presentation_points.to_s.split("<paragraph>").each do |pp|
              - next unless pp =~ /\[\!\!/
              - img = pp.split("[!!")[1].split("!!]").first
              - @images.each do |imr|
                - if imr["name"] == img
                  %section{ :style => "vertical-align:top; text-align: left;" }
                    %h2
                      %img{ :src=> "#{imr['link']}" }
                  - break
          %section{ :style => "vertical-align:top; text-align: left;" }
            %h2
              #{finding.title}
            %h3
              Remediation Recommendations
            - if finding.presentation_rem_points
              %ul{ :style => "margin-left:10%" }
                - finding.presentation_rem_points.to_s.split("<paragraph>").each do |pp|
                  - if pp.gsub('</paragraph>','').size > 0
                    %li
                      #{pp.gsub('</paragraph>','')}
      %section
        %h2
          General Recommendations
      %section
        %h2
          Questions?

  %script{ :src => "/reveal.js/lib/js/head.min.js" }
  %script{ :src => "/reveal.js/js/reveal.js" }
  :javascript
    // Full list of configuration options available at:
    // https://github.com/hakimel/reveal.js#configuration
    Reveal.initialize({
      controls: true,
      progress: true,
      history: true,
      center: true,

      transition: 'slide', // none/fade/slide/convex/concave/zoom

      // Optional reveal.js plugins
      dependencies: [
        { src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
        { src: '/reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
        { src: '/reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
        { src: '/reveal.js/plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
        { src: '/reveal.js/plugin/zoom-js/zoom.js', async: true },
        { src: '/reveal.js/plugin/notes/notes.js', async: true }
      ]
    });
